/** ***********************************************
 * CodeGen
 *
 * @author  Jonnie Spratley
 * @date 3/05/2009
 * @licence MCIYC
 * @website http://jonniespratley.com/code
 * @contact jonniespratley@gmail.com
 *********************************************** */
package com.jonniespratley.codegen.model
{
	import com.adobe.cairngorm.model.IModelLocator;
	import com.jonniespratley.codegen.managers.AssetManager;
	import com.jonniespratley.codegen.vo.ConfigVO;
	import com.jonniespratley.codegen.vo.Database;
	import com.jonniespratley.codegen.vo.Field;
	import com.jonniespratley.codegen.vo.FileVO;
	import com.jonniespratley.codegen.vo.OptionsVO;
	import com.jonniespratley.codegen.vo.PHPClassVO;
	import com.jonniespratley.codegen.vo.PHPMethodVO;
	import com.jonniespratley.codegen.vo.SchemaVO;
	import com.jonniespratley.codegen.vo.Table;
	
	import mx.collections.ArrayCollection;

	[Bindable]
	public final class ModelLocator implements IModelLocator
	{
		/**
		 * Defines the Singleton instance of the Application ModelLocator
		 */
		private static var instance:ModelLocator;

		public function ModelLocator()
		{
			if( instance != null ) throw new Error( "Error: Singletons can only be instantiated via getInstance() method!" );

			ModelLocator.instance = this;
		}

		/**
		 * Returns the Singleton instance of the Application ModelLocator
		 */
		public static function getInstance():ModelLocator
		{
			if( instance == null )	instance = new ModelLocator();

			return instance;
		}

		// *********** Public Variables that our views are going to bind to ************** \\
		public var DEBUG:String = '';


		public var showResults:Boolean = false;
		public var showSettings:Boolean = false;
		public var showResultsLabel:String = 'Show Results';

		public var sampleResultObject:Array = [
			{ label: 'Result',
			children: [
				{
					name: 'currentUser',
					type: 'String',
					value: 'Jonnie'
				},
				{
					name: 'os',
					type: 'String',
					value: 'Darwin 2.38389'
				},
				{
					name: 'phpVersion',
					type: 'String',
					value: '5.2'
				},
				{
					name: 'mysqlVersion',
					type: 'String',
					value: '5.0'
				}
			] }
		];

 


			public var codeInfoFrameworks:Array = [ 
				{ label: 'Cairngorm', data: 'Cairngorm' }, 
				{ label: 'AS 3/None', data: 'AS3' } 
			];
			
			public var codeInfoRPC:Array = [ 
				{ label: 'HTTP - HTTPService', data: 'HTTPService' }, 
				{ label: 'HTTP - URLLoader/URLRequest', data: 'URLLoader' }, 
				{ label: 'AMF - AMFPHP', data: 'AMFPHP' },
				{ label: 'AMF - WebORB', data: 'Weborb' } 
			];
			
			public var codeFolderStructure:Array = [
				{ label: 'Application', 
					children: [
						{ label: 'com' ,
						  children: [ {label: 'project'} ] }
					]
				}
			];
			
			
		public var tempClientPreview:Array;
		public var tempServerPreview:Array;
		public var selectedOption:OptionsVO;
		public var usersDatabaseModels:ArrayCollection = new ArrayCollection();
		public var applicationCollection:ArrayCollection;
		public var options:OptionsVO;
		public var generatedServerOutput:Array;
		public var currentWindowUrl:String = '';
		public var configTree:ArrayCollection;
		
		public var directoryTree:ArrayCollection;
		
		public var applicationTree:ArrayCollection;
		public var phpTemplateTree:ArrayCollection;
		public var flexTemplateTree:ArrayCollection;
		
		public var cairngormTemplateTree:ArrayCollection;
		public var outputCollection:ArrayCollection;
		
		public var serviceResultCollection:ArrayCollection;
		public var servicesCollection:ArrayCollection;
		
		public var generatedCodeCollection:ArrayCollection;
		
		public var selectedService:FileVO;
		public var selectedPHPClass:PHPClassVO;
		public var selectedPHPMethod:PHPMethodVO;
		public var selectedFile:FileVO;
		public var selectedTemplate:FileVO;
		public var selectedDatabase:Database;
		public var selectedTable:Table;
		public var selectedField:Field;
		
 

		public var phpClassCollection:ArrayCollection;
		public var templateTreeCollection:ArrayCollection;

		public var methodCollection:ArrayCollection;
		public var directoryCollection:ArrayCollection;
		public var fileContents:String = '';
		public var currentConfig:ConfigVO;
		public var currentSchema:SchemaVO;
		public var configLocation:String = '';
		public var schemaLocation:String = '';
		
		public var databaseCollection:ArrayCollection;
		public var configCollection:ArrayCollection;
		public var schemaCollection:ArrayCollection;

		public var applicationDump:String = '';



		public var inspectedClassCollection:ArrayCollection;
		public var assets:AssetManager = new AssetManager();

		public var tipHost:String = 'This is the host of your database that you are trying to access, it is most likely "localhost".';
		public var tipUser:String = 'The username that you use to access the MySQL server on the specified host.';
		public var tipPass:String = 'The password for the username you just specified.';
		public var tipDatabase:String = 'This needs to be a valid database that is on the specified host.';
		public var tipApplication:String = 'Name of your application, this is needed for the naming of your Main.mxml file that is going to be generated.';
		public var tipNamespace:String = 'This is going to be reverse domain style, this is usually the developers domain for uniqueness in the application classes. Example: com.jonniespratley.testproject';
		public var tipServices:String = 'This needs to be the URL of the location where the service files which will be placed. If you don\'t know yet, that is ok, you will just have to go into the client side source and fix the url.';
		public var tipFramework:String = 'This is going to be if you are using the Cairngorm framework, or just general application with no framework. You will still have a model and objects that represent your tables regardless of the response. If you don\'t know just choose General Flex HTTPService.';
		public var tipCopywrite:String = 'Please put a copywrite or something that you would like in head of all pages generated.';
		public var tipConfigFile:String = '';
		public var tipSchemaFile:String = '';
		public var tipConfigLocation:String = '';
		public var tipSchemaLocation:String = '';
















		// ***************** Public Static Variables for Work View States ************* \\
		public var workflowState:uint = 0;
		public static const LOGIN_SCREEN:uint = 0;
		public static const WELCOME_SCREEN:uint = 1;
	}
}